<template>
<div class="home">
  <div class="icon">
    <van-swipe class="my-swipe"  :show-indicators="false">
      <van-swipe-item v-for="(page,idx) in pages" :key="idx">
        <div class="item" v-for="(item,idx) in page" :key="idx">
          <div class="icon-img">
            <img
              :src=item.imgUrl
              alt=""
            />
          </div>
          <div class="icon-desc">金典热卖金典热卖</div>
        </div>
      </van-swipe-item>
    </van-swipe>
  </div>
  </div>
</template>

<script>
export default {
  name: 'homeIcon',
  data () {
    return {
      imgList: [
        {
          id: '001',
          imgUrl:
            'https://img.alicdn.com/imgextra/i3/O1CN01GJi5xP26WSH9MFxaE_!!6000000007669-2-tps-140-140.png'
        },
        {
          id: '002',
          imgUrl:
            'https://img.alicdn.com/imgextra/i4/O1CN01JXGsNw1Klw6ScU2ur_!!6000000001205-2-tps-128-152.png'
        },
        {
          id: '003',
          imgUrl:
            'https://img.alicdn.com/imgextra/i2/O1CN0132chN91jKKd6vCwL9_!!6000000004529-2-tps-148-148.png'
        },
        {
          id: '004',
          imgUrl:
            'https://img.alicdn.com/imgextra/i4/O1CN01OcRPBM1Kudd7dan55_!!6000000001224-2-tps-140-156.png'
        },
        {
          id: '005',
          imgUrl:
            'https://img.alicdn.com/imgextra/i3/O1CN01GJi5xP26WSH9MFxaE_!!6000000007669-2-tps-140-140.png'
        },
        {
          id: '006',
          imgUrl:
            'https://img.alicdn.com/imgextra/i4/O1CN01JXGsNw1Klw6ScU2ur_!!6000000001205-2-tps-128-152.png'
        },
        {
          id: '007',
          imgUrl:
            'https://img.alicdn.com/imgextra/i2/O1CN0132chN91jKKd6vCwL9_!!6000000004529-2-tps-148-148.png'
        },
        {
          id: '008',
          imgUrl:
            'https://img.alicdn.com/imgextra/i4/O1CN01OcRPBM1Kudd7dan55_!!6000000001224-2-tps-140-156.png'
        },
        {
          id: '009',
          imgUrl:
            'https://img.alicdn.com/imgextra/i3/O1CN01GJi5xP26WSH9MFxaE_!!6000000007669-2-tps-140-140.png'
        },
        {
          id: '010',
          imgUrl:
            'https://img.alicdn.com/imgextra/i4/O1CN01JXGsNw1Klw6ScU2ur_!!6000000001205-2-tps-128-152.png'
        },
        {
          id: '011',
          imgUrl:
            'https://img.alicdn.com/imgextra/i2/O1CN0132chN91jKKd6vCwL9_!!6000000004529-2-tps-148-148.png'
        },
        {
          id: '012',
          imgUrl:
            'https://img.alicdn.com/imgextra/i4/O1CN01OcRPBM1Kudd7dan55_!!6000000001224-2-tps-140-156.png'
        }
      ]
    }
  },
  props: {
    iconList: Array
  },
  computed: {
    pages () {
      const pages = []
      this.iconList.forEach((item, idx) => {
        const page = Math.floor(idx / 8)
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  }
}
</script>

<style lang="scss" >
@import "~@/assets/css/vertauls.scss";
.icon {
  overflow: hidden;
  height: 0;
  padding-bottom: 50%;
  margin-top: 5px;
  .van-swipe{
    height: 0;
    padding-bottom: 50%;
    .van-swipe__track {
        height: 0;
        padding-bottom: 50%;
        .van-swipe-item{
            width: 25%;
            height: 0;
        }
    }
  }
  .item {
    float: left;
    position: relative;
    overflow: hidden;
    width: 25%;
    height: 0;
    padding-bottom: 25%;
    .icon-img {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 30px;
      padding: 30px;
      img {
        display: block;
        margin: 0 auto;
        height: 100%;
      }
    }
    .icon-desc {
      position: absolute;
      bottom: 0;
      width: 100%;
      line-height: 30px;
      text-align: center;
      font-size: 24px;
      margin-bottom: 10px;
      padding: 0 20px;
    //   overflow: hidden;
    //   white-space:nowrap ;
    //   text-overflow: ellipsis;
        @include ellip
    }
       }
  }

</style>
